package com.ccom.core.common.util;

import com.alibaba.fastjson.JSONArray;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 判空工具
 * @auther: jjzhang24
 * @date: 2021年12月13日
 */
public class EmptyUtils {

    /**
     * @Description: 判断Long类型的对象是否为空或小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isIllegalId(Long l) {
        if (null == l || l <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断Long类型的对象是否为空或小于零，用于特殊场景
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isNullId(Long l) {
        if (null == l || l < 0) {
            return true;
        }
        return false;
    }

    /**
     * @param i
     * @Description: 判断Integer类型的对象是否为空或小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isIllegalId(Integer i) {
        if (null == i || i <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断Integer类型的对象是否为空或小于零，用于特殊场景
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isNullId(Integer i) {
        if (null == i || i < 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断List是否为空或者长度小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isEmpty(List<?> list) {
        if (null == list || list.size() <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断Set是否为空或者长度小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isEmpty(Set<?> set) {
        if (null == set || set.size() <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断map是否为空或者长度小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isEmpty(Map<?, ?> map) {
        if (null == map || map.size() <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断JSONArray是否为空或者长度小于等于零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isEmpty(JSONArray array) {
        if (null == array || array.size() <= 0) {
            return true;
        }
        return false;
    }

    /**
     * @Description: 判断数组是否为空或零
     * @Author: jjzhang24
     * @Date: 2021/12/13
     */
    public static boolean isIllegalArray(Object[] objs) {
        if (objs == null || objs.length == 0) {
            return true;
        }
        return false;
    }
}
